// pages/booking/booking.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    seat1:0,
    seat2:0,
    seat3:0,
    seat4:0,
    seat5:0,
    seat6:0,
    seat7:0,
    seat8:0,
    seat9:0,
    seat10:0,
    seat11:0,
    seat12:0,
    seat13:0,
    seat14:0,
    seat15:0,
    seat16:0,
    seat17:0,
    seat18:0,
    seat19:0,
    seat20:0,
    selectId:"",
    filmId:"",
    cinemaId:"",
    seats:[],
    deng:"",
    username:"",
    filmImg:"",
    filmName:"",
    playTime:"",
    cinemaName:"",
    address:"",
    price:0,
    balance:0
  },

  buy(e){
    let that=this;
    console.log(that.data.username),
    console.log(that.data.price),
    console.log(that.data.balance);
    if(that.data.balance>that.data.price){
      wx.request({
      url: "http://localhost:8080/user/buy",
      method: "POST",
      header: {
        'content-type': 'application/json'
      },
      
      data: {
        username:that.data.username,
        price:that.data.price,
        balance:that.data.balance
      },
      // res.data表示成功的时候返回的数据
      success(res) {
        // console.log(res.data);
        if (res.data.code == 200) {
          if(1){
            console.log(that.data.cinemaId)
            if(that.data.selectId==1){
              wx.request({
                url: "http://localhost:8080/seat/update1",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat1:2
                },
              });
              that.setData({
                selectId:""
              })
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:1,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address,
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==2){
              wx.request({
                url: "http://localhost:8080/seat/update2",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat2:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:2,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==3){
              wx.request({
                url: "http://localhost:8080/seat/update3",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat3:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:3,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==4){
              wx.request({
                url: "http://localhost:8080/seat/update4",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat4:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:4,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==5){
              wx.request({
                url: "http://localhost:8080/seat/update5",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat5:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:5,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==6){
              wx.request({
                url: "http://localhost:8080/seat/update6",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat6:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:6,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==7){
              wx.request({
                url: "http://localhost:8080/seat/update7",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat2:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:7,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==8){
              wx.request({
                url: "http://localhost:8080/seat/update8",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat8:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:8,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==9){
              wx.request({
                url: "http://localhost:8080/seat/update9",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat9:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:9,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==10){
              wx.request({
                url: "http://localhost:8080/seat/update10",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat10:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:10,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==11){
              wx.request({
                url: "http://localhost:8080/seat/update11",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat11:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:11,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==12){
              wx.request({
                url: "http://localhost:8080/seat/update12",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat12:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:12,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==13){
              wx.request({
                url: "http://localhost:8080/seat/update13",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat13:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:13,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==14){
              wx.request({
                url: "http://localhost:8080/seat/update14",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat14:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:14,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==15){
              wx.request({
                url: "http://localhost:8080/seat/update15",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat15:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:15,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==16){
              wx.request({
                url: "http://localhost:8080/seat/update16",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat16:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:16,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==17){
              wx.request({
                url: "http://localhost:8080/seat/update17",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat17:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:17,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==18){
              wx.request({
                url: "http://localhost:8080/seat/update18",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat18:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:18,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==19){
              wx.request({
                url: "http://localhost:8080/seat/update19",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat19:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:19,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
            else if(that.data.selectId==20){
              wx.request({
                url: "http://localhost:8080/seat/update20",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  filmId:that.data.filmId,
                  cinemaId:that.data.cinemaId,
                  seat20:2
                },
              });
              wx.showToast({
                //标识提示信息
                title: '购买成功',
                //图标显示类型
                icon: 'success',
                duration: 2000,
                //显示透明蒙层，防止触摸穿透
                mask: true
              });
              wx.request({
                url: "http://localhost:8080/book/update",
                method: "POST",
                header: {
                  'content-type': 'application/json'
                },
                
                data: {
                  orderNum:that.data.username,
                  filmImage:that.data.filmImg,
                  filmId:that.data.filmId,
                  filmName:that.data.filmName,
                  cinemaId:that.data.cinemaId,
                  seatNum:20,
                  playTime:that.data.playTime,
                  username:that.data.username,
                  cinemaName:that.data.cinemaName,
                  address:that.data.address
                },
              });
              setTimeout(function(){
              wx.switchTab({
                //相对绝对都可
                url: '/pages/homePage/homePage'
            })
              },2000)
            }
          }
          else{
            wx.showToast({
              //标识提示信息
              title: '购买失败，请充值',
              //图标显示类型
              icon: 'fail',
              duration: 2000,
              //显示透明蒙层，防止触摸穿透
              mask: true
          })
          }
        }
      }
      });}
    else{
      wx.showToast({
        //标识提示信息
        title: '想锤呢，自个儿氪金去',
        //图标显示类型
        icon: 'none',
        duration: 2000,
        //显示透明蒙层，防止触摸穿透
        mask: true
      });
    }
  },

  select1(e){
    console.log(e.currentTarget.id)
    this.setData({
      seat1:1,
      selectId:e.currentTarget.id
    })
  },

  cancel1(e){
    console.log(e)
    this.setData({
      seat1:0,
      selectId:""
    })
  },
  select2(e){
    this.setData({
      seat2:1,
      selectId:e.currentTarget.id
    })
    console.log(this.data.selectId)
  },

  cancel2(e){
    console.log(e.currentTarget.id)
    this.setData({
      seat2:0,
      selectId:""
    })
  },
  select3(e){
    this.setData({
      seat3:1,
      selectId:e.currentTarget.id
    })
  },

  cancel3(e){
    this.setData({
      seat3:0,
      selectId:""
    })
  },
  select4(e){
    this.setData({
      seat4:1,
      selectId:e.currentTarget.id
    })
  },

  cancel4(e){
    this.setData({
      seat4:0,
      selectId:""
    })
  },
  select5(e){
    this.setData({
      seat5:1,
      selectId:e.currentTarget.id
    })
  },

  cancel5(e){
    this.setData({
      seat5:0,
      selectId:""
    })
  },
  select6(e){
    this.setData({
      seat6:1,
      selectId:e.currentTarget.id
    })
  },

  cancel6(e){
    this.setData({
      seat6:0,
      selectId:""
    })
  },
  select7(e){
    this.setData({
      seat7:1,
      selectId:e.currentTarget.id
    })
  },

  cancel7(e){
    this.setData({
      seat7:0,
      selectId:""
    })
  },
  select8(e){
    this.setData({
      seat8:1,
      selectId:e.currentTarget.id
    })
  },

  cancel8(e){
    this.setData({
      seat8:0,
      selectId:""
    })
  },
  select9(e){
    this.setData({
      seat9:1,
      selectId:e.currentTarget.id
    })
  },

  cancel9(e){
    this.setData({
      seat9:0,
      selectId:""
    })
  },
  select10(e){
    this.setData({
      seat10:1,
      selectId:e.currentTarget.id
    })
  },

  cancel10(e){
    this.setData({
      seat10:0,
      selectId:""
    })
  },
  select11(e){
    this.setData({
      seat11:1,
      selectId:e.currentTarget.id
    })
  },

  cancel11(e){
    this.setData({
      seat11:0,
      selectId:""
    })
  },
  select12(e){
    this.setData({
      seat12:1,
      selectId:e.currentTarget.id
    })
  },

  cancel12(e){
    this.setData({
      seat12:0,
      selectId:""
    })
  },
  select13(e){
    this.setData({
      seat13:1,
      selectId:e.currentTarget.id
    })
  },

  cancel13(e){
    this.setData({
      seat13:0,
      selectId:""
    })
  },
  select14(e){
    this.setData({
      seat14:1,
      selectId:e.currentTarget.id
    })
  },

  cancel14(e){
    this.setData({
      seat14:0,
      selectId:""
    })
  },
  select15(e){
    this.setData({
      seat15:1,
      selectId:e.currentTarget.id
    })
  },

  cancel15(e){
    this.setData({
      seat15:0,
      selectId:""
    })
  },
  select16(e){
    this.setData({
      seat16:1,
      selectId:e.currentTarget.id
    })
  },

  cancel16(e){
    this.setData({
      seat16:0,
      selectId:""
    })
  },
  select17(e){
    this.setData({
      seat17:1,
      selectId:e.currentTarget.id
    })
  },

  cancel17(e){
    this.setData({
      seat17:0,
      selectId:""
    })
  },
  select18(e){
    this.setData({
      seat18:1,
      selectId:e.currentTarget.id
    })
  },

  cancel18(e){
    this.setData({
      seat18:0,
      selectId:""
    })
  },
  select19(e){
    this.setData({
      seat19:1,
      selectId:e.currentTarget.id
    })
  },

  cancel19(e){
    this.setData({
      seat19:0,
      selectId:""
    })
  },
  select20(e){
    this.setData({
      seat20:1,
      selectId:e.currentTarget.id
    })
  },

  cancel20(e){
    this.setData({
      seat20:0,
      selectId:""
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    console.log(options);
    that.setData({
      filmId:options.filmId,
      cinemaId:options.cinemaId,
      filmName:options.filmName,
      filmImg:options.filmImg,
      playTime:options.playTime,
      cinemaName:options.cinemaName,
      address:options.address,
      price:options.price
    });
    that.data.price=parseInt(that.data.price);
    wx.request({
      url: "http://localhost:8080/seat/getById",
      method: "GET",
      header: {
        'content-type': 'application/json'
      },
      
      data: {
        filmId:options.filmId,
        cinemaId:options.cinemaId,
      },
      // res.data表示成功的时候返回的数据
      success(res) {
        // console.log(res.data);
        if (res.data.code == 200) {
          that.setData({
           seats:res.data.data
          })
          console.log(that.data.seats)
        }
      }
    });
    wx.request({
      url: "http://localhost:8080/user/getById",
      method: "GET",
      header: {
        'content-type': 'application/json'
      },
      
      data: {
        username:app.globalData.username
      },
      // res.data表示成功的时候返回的数据
      success(res) {
        // console.log(res.data);
        if (res.data.code == 200) {
          that.setData({
           balance:res.data.data.balance
          })
          console.log(that.data.balance)
        }
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if(!app.globalData.deng){
      wx.showToast({
          //标识提示信息
          title: '未登录，请先登录用户',
          //图标显示类型
          icon: 'none',
          duration: 2000,
          //显示透明蒙层，防止触摸穿透
          mask: true
      })
      setTimeout(function(){
        wx.switchTab({
          //相对绝对都可
          url: '/pages/user/user'
      })
      },2000)
     }
     this.setData({
       username:app.globalData.username
     })
     console.log(this.data.username)
     console.log(this.data.filmImg)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})